<template>
  <div class="admin-container">
    <el-container>
      
      <!-- 左侧导航菜单 -->
      <el-aside width="200px" class="admin-sidebar">
        <div class="logout-container">
          <el-button type="danger" @click="logout" class="logout-btn">退出登录</el-button>
        </div>
        <el-menu
          default-active="1"
          class="admin-menu"
          background-color="#1e88e5"
          text-color="#fff"
          active-text-color="#ffd04b"
        >
          <el-menu-item index="1" @click="router.push('/index/admin')">
            <el-icon><User /></el-icon>
            <span>用户管理</span>
          </el-menu-item>
          <el-menu-item index="2" @click="router.push('/index/info-control')">
            <el-icon><Document /></el-icon>
            <span>资讯管理</span>
          </el-menu-item>
          <el-menu-item index="3" @click="router.push('/index/products')">
            <el-icon><Goods /></el-icon>
            <span>商品界面</span>
          </el-menu-item>
          <el-menu-item index="4" @click="router.push('/index/product-data')">
            <el-icon><DataAnalysis /></el-icon>
            <span>商品数据</span>
          </el-menu-item>
          <el-menu-item index="5" @click="router.push('/index/appoint')">
            <el-icon><Calendar /></el-icon>
            <span>预约管理</span>
          </el-menu-item>
          <el-menu-item index="6" @click="router.push('/index/auth')">
            <el-icon><Lock /></el-icon>
            <span>权限管理</span>
          </el-menu-item>
          <el-menu-item index="7" @click="router.push('/index/userinfo')">
            <el-icon><UserFilled /></el-icon>
            <span>个人信息修改</span>
          </el-menu-item>
        </el-menu>
      </el-aside>

      <!-- 主内容区 -->
      <el-main class="admin-main">
        <RouterView/>
      </el-main>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import { store } from '@/common/store'
import router from '@/router'
import {
  User,
  Document,
  Goods,
  DataAnalysis,
  Calendar,
  Lock,
  UserFilled
} from '@element-plus/icons-vue'

const logout = () => {
  localStorage.removeItem('adminToken')
  sessionStorage.removeItem('token')
  sessionStorage.removeItem('userinfo')
  store.logined = false
  store.userinfo = {id:"",username:"",name:""}
  store.token = ""
  router.push('/login')
}
</script>

<style scoped>

/* 
*/.admin-container {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
}

.admin-header {
  background-color: #1e88e5;
  color: white;
  display: flex;
  align-items: center;
  padding-left: 20px;
  font-size: 16px;
  font-weight: bold;
  border-bottom: 1px solid #1565c0;
}

.logout-container {
  padding: 10px;
  text-align: center;
  border-bottom: 1px solid #1565c0;
}

.logout-btn {
  width: 90%;
  margin-bottom: 10px;
}

.admin-sidebar {
  background-color: #1e88e5;
  height: 100vh;
  flex-shrink: 0;
}

.admin-menu {
  border-right: none;
}

.admin-main {
  padding: 20px;
  background-color: #f5f7fa;
} 
</style>
